<?php
/**
 * Autor:   Miguel A. Zilli
 * Email:   miguelzilli@gmail.com
 */

class Instalacion extends AppModel {
    var $name = 'Instalacion';
    var $useTable = 'instalaciones';
    var $primaryKey = 'id';
    var $displayField = '';
    var $recursive = 0;
    var $order=array(
        'Instalacion.cant_inst'=>'ASC'
    );

    var $validate = array(
        'cant_inst' =>array(
            array('rule'=>'numeric','message'=>'Solo se permiten números.','allowEmpty' => false),
        )
    );

    var $belongsTo = array(
        'Instalacionestipo' => array(
            'className' => 'Instalacionestipo',
            'foreignKey' => 'instalacionestipo_id'
        ),
        'Revision' => array(
            'className' => 'Revision',
            'foreignKey' => 'revision_id'
        ),
        'Predio' => array(
            'className' => 'Predio',
            'foreignKey' => 'predio_id'
        )
    );

    public function beforeSave(){
        if(!empty($this->data['Instalacion'])){
            foreach($this->data['Instalacion'] as $campo=>$valor){
                $this->data['Instalacion'][$campo]=strtoupper($valor);
            }
        }
        return true;
    }
}
?>